Skip to content

Test WebApplicationBuilder with WebApplicationFactory #63196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

BrennanConroy
Copy link
Member

Adding test per #62782 (comment)
Also, readding WebHostBuilder test that was converted to HostBuilder so we keep test coverage.

@Copilot Copilot AI review requested due to automatic review settings August 8, 2025 18:33
@BrennanConroy BrennanConroy requested a review from a team as a code owner August 8, 2025 18:33
@github-actions github-actions bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Aug 8, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds test coverage for WebApplicationBuilder with WebApplicationFactory and ensures continued test coverage for WebHostBuilder. The changes address a specific testing gap identified in issue #62782.

  • Adds a new test TestingInfrastructure_WebApplicationBuilder_RespectsCustomizations to verify WebApplicationBuilder works correctly with WebApplicationFactory
  • Reverts BasicWebSite to use WebHostBuilder instead of HostBuilder to maintain test coverage for the deprecated pattern
  • Updates existing test assertions to distinguish between different CreateServer method overloads

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Mvc/test/WebSites/BasicWebSite/Program.cs Reverted from HostBuilder to WebHostBuilder to maintain test coverage
src/Mvc/test/Mvc.FunctionalTests/TestingInfrastructureInheritanceTests.cs Added new test for WebApplicationBuilder and updated assertions to track different server creation methods

factory.StartServer();

// Assert
Assert.Equal(["ConfigureWebHost"], factory.ConfigureWebHostCalled.ToArray());
Copy link
Preview

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Use collection expression syntax consistently. The array literal syntax ["ConfigureWebHost"] is being used here, but line 27 uses new[] { ... }. Consider using the newer collection expression syntax throughout for consistency.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant